package bTree.LeetCode;

public class H指数2 {
    public int hIndex(int[] citations) {
        int result=0;
        int length = citations.length;
        int left=0,right=length-1;
        while (left<=right){
            int midIndex=(left+right)/2;
            int index=length-midIndex;
            int mid = citations[midIndex];
            if(mid>=index){
                result=index;
                right=midIndex-1;
            } else{
                left=midIndex+1;
            }
        }
        return result;
    }
}